package de.uni.bremen.estudent.lbs.views;


import android.content.Context;
import android.graphics.Canvas;
import android.widget.ImageView;

import de.uni.bremen.estudent.lbs.R;


/**
 * @author bahlfeld
 */
public final class CompasView extends ImageView {
    /**
     * holds the direction of the view.
     */
    int mDirection = 0;

    /**
     * Constructor of the class.
     * 
     * @param context The application context.
     */
    public CompasView(final Context context) {
        super(context);

        this.setImageResource(R.drawable.dienstleistung);
    }

    @Override
    public void onDraw(final Canvas canvas) {
        int height = this.getHeight();
        int width = this.getWidth();

        canvas.rotate(-mDirection, width / 2, height / 2);

        super.onDraw(canvas);
    }

    /**
     * Sets the direction for drawing.
     * 
     * @param direction Direction as int value.
     */
    public void setDirection(final int direction) {
        mDirection = direction;
        this.invalidate();
    }

}
